package studio7.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import studio7.dao.ReservaDAO;
import studio7.exception.DAOException;

/**
 * Servlet implementation class EliminarReservaServlet
 */
@WebServlet("/EliminarReservaServlet")
public class EliminarReservaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EliminarReservaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		    String usuario = request.getParameter("usuario");
	        String fecha = request.getParameter("fecha");
	        String sala = request.getParameter("sala");
	        int idReserva = 0;
	        
	        ReservaDAO reserv = new ReservaDAO();
	        
	        try {
	        	idReserva=	reserv.buscarReserva(usuario);
			} catch (DAOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			String reservaID = ""+idReserva;
			request.setAttribute("USUARIO", usuario);

			
			request.setAttribute("FECHA", fecha);

			request.setAttribute("SALA", sala);
			
			request.setAttribute("IDRESERVA", reservaID);
			
			
			RequestDispatcher rd = request
					.getRequestDispatcher("EliminarReservaEncontrado.jsp");
			rd.forward(request, response);
	}

}
